#ifndef __MSG_MAP_H__
#define __MSG_MAP_H__
//==================================================
#include <windows.h>
#include <stdio.h>
//==================================================
typedef LRESULT (*MSGFN)(HWND hWnd, WPARAM wParam, LPARAM lParam);
//==================================================
struct MSGMAP
{
	UINT uMsg;
	MSGFN MsgFn;
};
//==================================================
#define DECLEAAR_MSGMAP(name) extern MSGMAP g_##name[];
#define MSGMAP_BEG(name) MSGMAP g_##name[]={
#define MSGMAP_SET(msg, name) {msg, name},
#define MSGMAP_END() {WM_NULL, NULL}};
//==================================================
#define DECLEAR_MSGFN(name) LRESULT name(HWND hWnd, WPARAM wParam, LPARAM lParam);
#define IMPLEMENT_MSGFN(name) LRESULT name(HWND hWnd, WPARAM wParam, LPARAM lParam)
//==================================================
#define DECLEAR_WNDPROC(name) LRESULT CALLBACK name##Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#define GET_PROC(name) name##Proc
#define IMPLEMENT_WNDPROC(name) LRESULT CALLBACK name##Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\
{\
	MSGMAP *pTemp = g_##name;\
	while(WM_NULL != pTemp->uMsg)\
	{\
		if(uMsg == pTemp->uMsg)\
		{\
			return pTemp->MsgFn(hWnd, wParam, lParam);\
		}\
		pTemp++;\
	}\
	return DefWindowProc(hWnd, uMsg, wParam, lParam);\
}
//==================================================
#endif